
# ---
# apiVersion: storage.k8s.io/v1
# kind: StorageClass
# metadata:
#   name: local-storage
# provisioner: kubernetes.io/no-provisioner
# volumeBindingMode: WaitForFirstConsumer

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: 1s-server-home
  labels:
    type: local
    app: 1s
spec:
  storageClassName: local-storage
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/home/1s/server-home"

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: 1s-server-logs
  labels:
    type: local
    app: 1s
spec:
  storageClassName: local-storage
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/home/1s/server-logs"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: 1s-server-home
  labels:
    app: 1s
    type: local
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: 1s-server-logs
  labels:
    app: 1s
    type: local
spec:
  storageClassName: local-storage
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: 1s-postgres-pv
  labels:
    app: postgres
    type: local
spec:
  storageClassName: local-storage
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/home/1s/var/data"

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: 1s-postgres-pv-claim
  labels:
    app: postgres
spec:
  storageClassName: local-storage
  capacity:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-configuration
  labels:
    app: postgres
data:
  POSTGRES_DB: postgressdb
  POSTGRES_USER: postgressuser
  POSTGRES_PASSWORD: postgresspassword

---
apiVersion: v1
kind: Service
metadata:
  name: postgres-service
  labels:
    app: postgres
spec:
  ports:
  - port: 5432
    name: postgres
  type: NodePort 
  selector:
    app: postgres

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgres-statefulset
  labels:
    app: postgres
spec:
  serviceName: "postgres"
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:12
        envFrom:
        - configMapRef:
            name: postgres-configuration
        ports:
        - containerPort: 5432
          name: postgresdb
        volumeMounts:
        - name: pv-data
          mountPath: /var/lib/postgresql/data
      volumes:
      - name: pv-data
        persistentVolumeClaim:
          claimName: 1s-postgres-pv-claim

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: s-deployment
  labels:
    name: 1s
    app: 1s
spec:
  replicas: 1
  selector:
    matchLabels:
      app: 1s
  template:
    metadata:
      labels:
        app: 1s
    spec:
      containers:
      - name: s-server
        image: djsasha777/1s-server:7
        resources:
          requests:
            cpu: "1"
            memory: "799M"
          limits:
            cpu: "2"
            memory: "1000M"
        command: [ "sleep" ]
        args: [ "infinity" ]
        ports:
        - containerPort: 1540
        - containerPort: 1541
        - containerPort: 1545
        - containerPort: 1560
        - containerPort: 1561
        - containerPort: 1562
        - containerPort: 1563
        - containerPort: 1564
        - containerPort: 1565
        - containerPort: 1566
        - containerPort: 1567
        - containerPort: 1568
        - containerPort: 1569
        - containerPort: 1570
        - containerPort: 1571
        - containerPort: 1572
        - containerPort: 1573
        - containerPort: 1574
        - containerPort: 1575
        - containerPort: 1576
        - containerPort: 1577
        - containerPort: 1578
        - containerPort: 1579
        - containerPort: 1580
        - containerPort: 1581
        - containerPort: 1582
        - containerPort: 1583
        - containerPort: 1584
        - containerPort: 1585
        - containerPort: 1586
        - containerPort: 1587
        - containerPort: 1588
        - containerPort: 1589
        - containerPort: 1590
        - containerPort: 1591
        volumeMounts:
          - name: 1s-server-home
            mountPath: /home/usr1cv8
          - name: 1s-server-logs
            mountPath: /var/log/1C
      volumes:
        - name: 1s-server-home
          persistentVolumeClaim:
            claimName: 1s-server-home
        - name: 1s-server-logs
          persistentVolumeClaim:
            claimName: 1s-server-logs

---
apiVersion: v1
kind: Service
metadata:
  name: s-service
  labels:
    name: 1s
    app: 1s
spec:
  selector:
    app: 1s
  ports:
    - name: port1540
      protocol: TCP
      port: 1540
      targetPort: 1540
    - name: port1541
      protocol: TCP
      port: 1541
      targetPort: 1541
    - name: port1545
      protocol: TCP
      port: 1545
      targetPort: 1545
    - name: port1560
      protocol: TCP
      port: 1560
      targetPort: 1560
    - name: port1561
      protocol: TCP
      port: 1561
      targetPort: 1561
    - name: port1562
      protocol: TCP
      port: 1562
      targetPort: 1562
    - name: port1563
      protocol: TCP
      port: 1563
      targetPort: 1563
    - name: port1564
      protocol: TCP
      port: 1564
      targetPort: 1564
    - name: port1565
      protocol: TCP
      port: 1565
      targetPort: 1565
    - name: port1566
      protocol: TCP
      port: 1566
      targetPort: 1566
    - name: port1567
      protocol: TCP
      port: 1567
      targetPort: 1567
    - name: port1568
      protocol: TCP
      port: 1568
      targetPort: 1568
    - name: port1569
      protocol: TCP
      port: 1569
      targetPort: 1569
    - name: port1570
      protocol: TCP
      port: 1570
      targetPort: 1570
    - name: port1571
      protocol: TCP
      port: 1571
      targetPort: 1571
    - name: port1572
      protocol: TCP
      port: 1572
      targetPort: 1572
    - name: port1573
      protocol: TCP
      port: 1573
      targetPort: 1573
    - name: port1574
      protocol: TCP
      port: 1574
      targetPort: 1574
    - name: port1575
      protocol: TCP
      port: 1575
      targetPort: 1575
    - name: port1576
      protocol: TCP
      port: 1576
      targetPort: 1576
    - name: port1577
      protocol: TCP
      port: 1577
      targetPort: 1577
    - name: port1578
      protocol: TCP
      port: 1578
      targetPort: 1578
    - name: port1579
      protocol: TCP
      port: 1579
      targetPort: 1579
    - name: port1580
      protocol: TCP
      port: 1580
      targetPort: 1580
    - name: port1581
      protocol: TCP
      port: 1581
      targetPort: 1581
    - name: port1582
      protocol: TCP
      port: 1582
      targetPort: 1582
    - name: port1583
      protocol: TCP
      port: 1583
      targetPort: 1583
    - name: port1584
      protocol: TCP
      port: 1584
      targetPort: 1584
    - name: port1585
      protocol: TCP
      port: 1585
      targetPort: 1585
    - name: port1586
      protocol: TCP
      port: 1586
      targetPort: 1586
    - name: port1587
      protocol: TCP
      port: 1587
      targetPort: 1587
    - name: port1588
      protocol: TCP
      port: 1588
      targetPort: 1588
    - name: port1589
      protocol: TCP
      port: 1589
      targetPort: 1589
    - name: port1590
      protocol: TCP
      port: 1590
      targetPort: 1590
    - name: port1591
      protocol: TCP
      port: 1591
      targetPort: 1591

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: s-web-deployment
  labels:
    name: 1s-web
    app: 1s-web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: 1s-web
  template:
    metadata:
      labels:
        app: 1s-web
    spec:
      containers:
      - name: s-server
        image: djsasha777/1s-web-server:2
        resources:
          requests:
            cpu: "1"
            memory: "799M"
          limits:
            cpu: "2"
            memory: "1000M"
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: s-web-service
  labels:
    name: 1s-web
    app: 1s-web
spec:
  type: LoadBalancer
  selector:
    app: 1s-web
  ports:
    - name: port80
      protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30580


